package test_3_19;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张杰
 * Date: 2022-03-20
 * Time: 17:11
 */
class Test {
    public void func() {
        System.out.println("func()");
    }
}
public class TestDemo3 {
    public static void main(String[] args) {
        //数据捕获时，只能捕获常量
        int a = 100;
        new Test() {
            @Override
            public void func() {
                System.out.println("重写了这个方法！");
                System.out.println("捕获变量："+a);
            }
        }.func();
    }
}
